<template>
  <div class="test">
    <div class="test-top">
      <div class="test-top-left"></div>
      <div class="test-top-right">课题列表</div>
    </div>
    <div class="test-content">
      <div class="test-content-title">
        <div
          class="origin"
          v-for="item in titleList"
          :key="item.id"
          @click="changeTab(item)"
          :class="{ curentClass: curentId == item.id }"
        >
          {{ item.val }}
        </div>
      </div>
      <div class="test-content-list">
        <div class="subjectClass" v-for="(item, index) in list" :key="item.id">
          <div class="left">
            <div class="left-name">
              <span>{{ index + 1 + "、" }}</span
              >{{ item.subjectName }}
            </div>
            <div class="left-day" v-if="item.Heaven">
              {{ item.Heaven }}
            </div>
          </div>
          <div class="right">
            <div
              class="right-status"
              :style="{
                color:
                  item.signUpStatus == '待申请'
                    ? '#F63011'
                    : item.signUpStatus == '已认领'
                    ? '#5DAC60'
                    : '#FFA200',
              }"
            >
              {{ item.signUpStatus }}
            </div>
            <div
              class="right-detail"
              @click="item.signUpStatus != '待申请' && queryDetail(item.id)"
            >
              <img
                :src="
                  require(item.signUpStatus == '待申请'
                    ? '../assets/images/search-dark.png'
                    : '../assets/images/search-light.png')
                "
                alt=""
              /><span :class="item.signUpStatus == '待申请' ? 'dark' : 'light'"
                >查看详情</span
              >
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      titleList: [
        //标题
        { id: 1, val: "文档共建" },
        { id: 2, val: "操作系统开发" },
        { id: 3, val: "系统应用开发" },
      ],
      list: [],
      project: "文档共建",
      curentId: "1",
    };
  },
  created() {
    this.search();
  },
  methods: {
    async search() {
      let res = await this.$axios.get("/signUp/getSubjectByCategory", {
        params: { project: this.project },
      });
      if (res.data.code == 0) {
        this.list = res.data.data;
      }
    },
    changeTab(item) {
      this.curentId = item.id;
      this.project = item.val;
      this.search();
    },
    async queryDetail(id) {
      let res = await this.$axios.get("/signUp/getSignBySubject", {
        params: { subjectId: id },
      });
      if (res.data.code == 0) {
        let status = res.data.data[0].signUpStatus;
        sessionStorage.setItem("detail", JSON.stringify(res.data.data[0]));
        this.$router.push(status == "3" ? "/detailCancel" : "/detail");
      }
    },
  },
};
</script>
<style lang="less" scoped>
.bac {
  height: 20px;
  line-height: 20px;
}
.test {
  padding: 0 160px;
  margin-bottom: 20px;
  .test-top {
    display: flex;
    align-items: center;
    margin-top: 60px;
    margin-bottom: 30px;
    .test-top-left {
      width: 4px;
      height: 24px;
      background: #385bbc;
      margin-right: 12px;
    }
    .test-top-right {
      height: 32px;
      font-size: 24px;
      font-weight: 400;
      line-height: 32px;
      color: #000000;
      opacity: 0.8;
    }
  }
  .test-content {
    .test-content-title {
      display: flex;
      margin-bottom: 24px;
      // justify-content: space-between;
      .origin {
        width: 180px;
        height: 72px;
        line-height: 72px;
        text-align: center;
        background: #fff;
        border-radius: 6px;
        cursor: pointer;
        font-size: 24px;
        color: #000000;
        opacity: 0.8;
        margin-right: 20px;
      }
      .curentClass {
        background: #4760ff;
        color: #ffffff;
        box-shadow: 0px 10px 16px rgba(0, 0, 0, 0.16);
      }
    }
    .test-content-list {
      background-color: #fff;
      .subjectClass {
        font-size: 14px;
        font-weight: 400;
        color: rgba(0, 0, 0, 0.6);
        margin: 0 20px;
        border-bottom: 0.25px solid rgba(0, 0, 0, 0.1);
        display: flex;
        justify-content: space-between;
        .left {
          max-width: 80%;
          padding: 17px 0 17px 0px;
          display: flex;
          .left-name {
            padding-right: 30px;
            .bac;
          }
          .left-day {
            font-size: 12px;
            opacity: 0.9;
            .bac;
          }
        }
        .right {
          display: flex;
          padding: 17px 0 17px 0px;
          .right-status {
            .bac;
          }
          .right-detail {
            .bac;
            img {
              width: 14px;
              height: 14px;
              margin: 0 2px 0 30px;
            }
            .light {
              cursor: pointer;
              color: #0a59f7;
            }
            .dark {
              cursor: not-allowed;
              color: gray;
            }
          }
        }
      }
    }
  }
}
</style>
